package com.itheima.demo2;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Demo {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor
                = new ThreadPoolExecutor(0,
                4,
                1,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1),
                new ThreadPoolExecutor.AbortPolicy());

        threadPoolExecutor.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行");
        });
        threadPoolExecutor.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行");
        });

        threadPoolExecutor.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行");
        });

        threadPoolExecutor.shutdown();

    }
}
